/*
 * @Author: huangtianyang 916072572@qq.com
 * @Date: 2023-12-30 08:49:58
 * @LastEditors: error: error: git config user.name & please set dead value or install git && error: git config user.email & please set dead value or install git & please set dead value or install git
 * @LastEditTime: 2024-06-03 11:06:39
 * @FilePath: \cxl-driving-training\src\apis\channel\index.ts
 */
import axios from '../../axios/index'

export interface channelOperationInterface {
    channelAddress?: string //渠道地址
    channelType?: number //1.微信公众号；2.抖音小程序
    deliveryEndDate?: string | null //投放结束时间 为null表示长期
    deliveryStartDate?: string | null //投放开始时间 为null表示长期
    deliveryType?: number //1.线上；2.线下
    id?: string
    remark?: string
}

export interface channelPageInterface {
    current: number
    size: number
    disable?: number //渠道状态 0启用 1禁用
    channelType?: number //	渠道类型
}
//新增渠道
export const channelAdd = (data: channelOperationInterface) => {
    return axios({
        method: 'post',
        url: '/api/system/channel/manage/add',
        data
    })
}
//编辑渠道信息
export const channelEdit = (data: channelOperationInterface) => {
    return axios({
        method: 'post',
        url: '/api/system/channel/manage/edit',
        data
    })
}
//获取单个渠道信息
export const channelById = (id: string) => {
    return axios({
        method: 'get',
        url: '/api/system/channel/manage/getDetailById',
        params: { id }
    })
}
//编辑渠道启用状态
export const channelDisable = (id: string, disable: number) => {
    return axios({
        method: 'post',
        url: '/api/system/channel/manage/updateDisable',
        data: { id, disable }
    })
}
//获取渠道分页列表
export const channelPage = (params: channelPageInterface) => {
    return axios({
        method: 'get',
        url: '/api/system/channel/manage/getPageList',
        params
    })
}
//删除渠道
export const channelDelete = (id: string) => {
    return axios({
        method: 'get',
        url: '/api/system/channel/manage/delete',
        params: { id }
    })
}
//生成渠道推广地址
export const channelPromotionUrl = () => {
    return axios({
        method: 'get',
        url: '/api/system/channel/manage/generate/url'
    })
}
